package com.wythe.mall.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.RelativeLayout;

import com.hb.dialog.myDialog.MyAlertDialog;
import com.wythe.mall.R;
import com.wythe.mall.base.BaseActivity;
import com.wythe.mall.utils.GotoActivity;
import com.wythe.mall.utils.SharePreferenceUtils;
import com.wythe.mall.utils.ToastUtil;
import com.wythe.mall.utils.UserManager;


public class CenterActivity extends BaseActivity {

    private Toolbar mainToolbar;
    private RelativeLayout passwordRelativeLayout;
    private RelativeLayout mobileRelativeLayout;
    private AppCompatTextView logoutTextView;

    private long logoutTimeLong;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mine_center);
        initView();
        initData();
    }

    public void initView() {
        mainToolbar = (Toolbar) findViewById(R.id.mainToolbar);
        passwordRelativeLayout = (RelativeLayout) findViewById(R.id.passwordRelativeLayout);
        mobileRelativeLayout = (RelativeLayout) findViewById(R.id.mobileRelativeLayout);
        logoutTextView = (AppCompatTextView) findViewById(R.id.logoutTextView);
        logoutTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MyAlertDialog myAlertDialog = new MyAlertDialog(CenterActivity.this);
                myAlertDialog.builder();
                myAlertDialog.setTitle("温馨提示");
                myAlertDialog.setMsg("你确定退出登录吗");
                myAlertDialog.setPositiveButton("确认", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        SharePreferenceUtils.removeString(CenterActivity.this, "KEY_TOKEN");
                        SharePreferenceUtils.removeString(CenterActivity.this, "NAME");
                        SharePreferenceUtils.removeString(CenterActivity.this, "AVATAR");
                        UserManager.getInstance().setLogin(false);
                        CenterActivity.this.finish();
                        Intent intent = new Intent(CenterActivity.this,MainActivity.class);
                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(intent);
                        CenterActivity.this.finish();
                    }
                });
                myAlertDialog.setNegativeButton("取消", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                    }
                });
                myAlertDialog.show();
            }
        });

    }

    public void initData() {

        logoutTimeLong = 0L;
        setToolbar(mainToolbar, "个人设置");

    }

    //自定义方法

    private void logout() {

    }

}
